//
//  WordDicTableViewCell.m
//  万词王
//
//  Created by rimi on 2016/11/30.
//  Copyright © 2016年 dongfumei. All rights reserved.
//

#import "WordDicTableViewCell.h"


@interface WordDicTableViewCell ()

@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *detailLabel;

@end

@implementation WordDicTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self.contentView  addSubview:self.nameLabel];
        [self.contentView addSubview:self.detailLabel];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    CGRect contentRect = self.detailLabel.frame;
    contentRect.size.width = kBaseWidth - 40;
    self.detailLabel.frame = contentRect;
    [self.detailLabel sizeToFit];
}

-(CGSize)sizeForText{
    CGRect rect = [self.detailLabel.text boundingRectWithSize:CGSizeMake(kBaseWidth - 40, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:AAFont(15)} context:nil];
    return rect.size;
}

-(UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]initWithFrame:AAdaptionRect(20, 10, kBaseWidth - 40, 30)];
        _nameLabel.textColor = MainColor;
        _nameLabel.font = AAFont(17);
        
    }
    return _nameLabel;
}

-(UILabel *)detailLabel{
    if (!_detailLabel) {
        _detailLabel = [[UILabel alloc]initWithFrame:AAdaptionRect(20, CGRectGetMaxY(self.nameLabel.frame)+10, kBaseWidth - 40, 0)];
        _detailLabel.font = AAFont(15);
        _detailLabel.textColor = [UIColor groupTableViewBackgroundColor];
        
    }
    return _detailLabel;
}

@end
